﻿<UserControl x:Class="PocoGen.Gui.Presentation.Views.ConnectionView"
             x:ClassModifier="internal"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="TextBox">
            <Setter Property="Margin" Value="2" />
            <Setter Property="Padding" Value="2" />
        </Style>
        <Style TargetType="Label">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="Margin" Value="2" />
        </Style>
        <Style TargetType="TextBlock">
            <Setter Property="Margin" Value="2" />
        </Style>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="2" />
            <Setter Property="Padding" Value="5" />
        </Style>
        <Style TargetType="CheckBox">
            <Setter Property="Margin" Value="2,10,2,2" />
            <Setter Property="Padding" Value="2" />
            <Setter Property="VerticalContentAlignment" Value="Top" />
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label>Database type:</Label>
        <ComboBox Grid.Column="1" ItemsSource="{Binding SchemaReaders}" SelectedItem="{Binding SelectedSchemaReader}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding DatabaseType}" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Button Grid.Column="2" Command="{Binding ConfigureSelectedSchemaReader}" ToolTip="Settings..." Padding="2">
            <Image Source="{StaticResource SettingsIcon}" Height="16" />
        </Button>

        <Label Grid.Row="1">Connection string:</Label>
        <TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding ConnectionString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"><Hyperlink NavigateUri="{Binding ConnectionStringHelpUrl}" IsEnabled="{Binding IsConnectionStringHelpEnabled}" RequestNavigate="Hyperlink_RequestNavigate">Connection string documentation</Hyperlink></TextBlock>

        <Button Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" Command="{Binding TestConnection}" Margin="2,10,2,2">Test connection</Button>

        <Button Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" Command="{Binding LoadTables}" Margin="2,10,2,2">Load Tables</Button>

        <CheckBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2" IsChecked="{Binding UseAnsiQuoting}">
            <TextBlock TextWrapping="Wrap">
                Use ANSI quoting<LineBreak />
                If this option is set, every identifier (table and colum names) in the output will be quoted with &quot;.
                Otherwise the database-specific quoting will be used and only for identifiers which need quoting.<LineBreak />
                Set this option if you want to use the generated output with different database engines.
            </TextBlock></CheckBox>
    </Grid>
</UserControl>
